<?php 
namespace app\model;

use app\validate\User as UserValidate;

class User extends Common
{	
	protected $table = "tp_user";
	
	public function add($data){
		// dump($data);
		// 验证数据的合法性
		$validate = new UserValidate();
		if(!$validate->scene('add')->check($data)){
			// dump($validate->getError());
			return $this->message(400,$validate->getError());
		}
		$result = User::create($data,true);
		if(!$result){
			return $this->message(400,'添加失败');
		}
		return $this->message(200,"添加成功");
	}
}	